<div class="location-0" id="content">

    <div class="location loc-1">
        <div class="car-list" id="car-list">


            <ul class="clean-list">

                <?foreach($car_list as $val):?>
                    <li class="car-item even " id="car27">
                        <div class="rouded-box">
                            <div class="rouded-box-left">
                                <div class="box-center">
                                    <h2><a title="<?=$val->name?>" href="<?=$url?>details?id=<?=$val->id?>"><?=$val->name?></a></h2>

                                    <div class="annotation">
                                        <?=$val->description?>
                                    </div>
                                    <!-- vlastnosti - sedy box -->
                                    <div class="itemCar-properties">
                                        <ul class="clean-list">

                                            <li title="Seat count" class="param-seatCount">
                                                <div class="param-title">seat count: </div>
                                                <div class="param-int"><?=$val->seat_count?></div>
                                            </li>

                                            <li title="Number of doors" class="param-doorCount">
                                                <div class="param-title">Number of doors: </div>
                                                <div class="param-int"><?=$val->num_of_doors?></div>
                                            </li>

                                            <li title="Luggage space capacity" class="param-bootCapacity">
                                                <div class="param-title">luggage space capacity: </div>
                                                <div class="param-int"><?=$val->luggage_capacity?></div>
                                            </li>

                                            <li title="A/T" class="param-autoTransmission">
                                                <div class="param-title">A/T: </div>
                                                <?if($val->auto_transmission){?>
                                                    <div class="param-boolean-true"><span>yes</span></div>
                                                    <?}else{?>
                                                    <div class="param-boolean-false"><span>no</span></div>   
                                                    <?}?>
                                            </li>

                                            <li title="A/C" class="param-airCondition">
                                                <div class="param-title">A/C: </div>
                                                <?if($val->ac){?>
                                                    <div class="param-boolean-true"><span>yes</span></div>
                                                    <?}else{?>
                                                    <div class="param-boolean-false"><span>no</span></div>   
                                                    <?}?>
                                            </li>

                                            <li title="Benzin" class="param-fuel last">
                                                <div class="param-title">A/C: </div>
                                                <?if($val->diesel){?>
                                                    <div class="param-fuel"><span>D</span></div>
                                                    <?}else{?>
                                                    <div class="param-fuel"><span>B</span></div>   
                                                    <?}?>

                                            </li>

                                        </ul>
                                    </div>
                                </div>
                                <div class="left-box">
                                    <div class="image-box">
                                        <a title="<?=$val->name?>" href="<?=$url?>details?id=<?=$val->id?>">

                                            <img alt="<?=$val->name?>" src="<?=$info_sis_url.$val->url?>_105_76.jpg" width="90">

                                        </a>
                                    </div>
                                    <!-- spotreba a emise - zluty box -->
                                    <div class="itemCar-co2-consumption">
                                        <ul>
                                            <li class="param-co2"><span class="green-text">CO<sub>2</sub>: </span> <?=$val->co2?> g/kg</li>
                                            <li class="param-fuelConsumption">:  <?=number_format($val->fuel_consumption,1,',', ' ')?> l/100km</li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                            <div class="itemCar-price-etc">
                                <?
                                    /* FIRST CALCULATE PERCENTAGE --> FORMULA X:100=CUR:TOTAL */                                    

                                    $x= (100*$val->score)/10;

                                ?>
                                <div class="itemCar-rating green-text">
                                    <div class="bar">
                                        <div style="width:<?=$x?>%" class="progress-bar"></div>
                                    </div>
                                </div>



                                <div class="rating-text green-text">
                                    <strong>

                                        Score <?=$val->score?>

                                    </strong>
                                </div>
                                <div class="online-user green-text"></div>
                                <div class="itemCar-price">


                                    <div class="list-price">
                                        <strong class="green-text">Day price:</strong>

                                        <?
                                            if(isset($u_data['no_days'])){
                                                switch($u_data['no_days']){
                                                    case $u_data['no_days']<=3:
                                                        echo '1-3 days - '.$val->day13price*$u_data['no_days'];
                                                        break;
                                                    case $u_data['no_days']>=4 && $no_days<=7:
                                                        echo '4-7 days - '.$val->day47price*$u_data['no_days'];
                                                        break;
                                                    case $u_data['no_days']>=8 && $no_days<=15:
                                                        echo '8-15 days - '.$val->day815price*$u_data['no_days'];
                                                        break;
                                                }
                                            }else{
                                                echo $val->day13price;
                                            }

                                        ?>&euro; 
                                    </div>

                                </div>
                                <div class="itemCar-reservation">

                                    <? if(!isset($browse_fleet)){ ?>
                                        <a class="btn-reservation" href="<?=$url?>step_3?id=<?=$val->id?>">Book now</a>
                                        <?}else{?>
                                        <a class="btn-reservation" href="<?=$url?>details?id=<?=$val->id?>">Book now</a>
                                        <?}?>
                                </div>
                            </div>
                        </div>
                    </li>
                    <?endforeach;?>
            </ul>

        </div>

    </div>

</div>

<? if(!isset($browse_fleet)){ ?>

    <div class="location-0" id="column">

        <form id="formReservationBasicData" method="post" action="<?=$url?>step_2">
        
        <div id="formReservationBasicDatahPreview" class="fieldset formReservationBasicDatahPreview">
            <fieldset>
                <legend><span>Your details</span></legend>

                <div class="fieldset-box" style="padding-bottom: 0;">

                    <dl class="formitem- formitem">
                        <dt>
                            <label class="element" for="">&nbsp;</label> 
                        </dt>
                        <dd>
                            <table width="100%" border="0" class="clean-tab">
                                <tbody>
                                    <tr>
                                        <td valign="top">
                                            <h4>Pick up</h4>
                                            <ul class="clean-list" id="fromData">
                                                <li><?=$this->session->userdata('pickup_loc_text')?></li>                          
                                                <li> <?=$this->session->userdata('pickup_date').', '.$this->session->userdata('fullfrom');?> h</li>
                                            </ul>
                                        </td>
                                        <td valign="top">
                                            <h4>Return</h4>
                                            <ul class="clean-list" id="destData">
                                                <li><?=$this->session->userdata('return_loc_text')?></li>
                                                <li><?=$this->session->userdata('return_date').', '.$this->session->userdata('fullto');?> h </li>
                                            </ul>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </dd>
                    </dl>
                    <dl class="formitem- formitem" style="margin-bottom: 13px;">
                        <dt><label class="element" for="">&nbsp;</label> </dt>
                        <dd>
                            <div>
                                <a onclick="
                                    $('#formReservationBasicDatahPreview').slideUp({duration:500,easing:'easeOutSine',
                                    complete:function(){
                                    $('#formReservationBasicDatah1').slideDown({duration:500,easing:'easeOutSine',
                                    complete:function(){
                                    $('#formReservationBasicDatah2').slideDown({duration:500,easing:'easeOutSine',
                                    complete:function(){
                                    $('#formReservationBasicDatah3').slideDown({duration:500,easing:'easeOutSine',
                                    complete:function(){
                                    }})
                                    }})
                                    }})
                                    }                                    
                                    });
                                    " href="#">Change details</a>
                            </div>
                        </dd>
                    </dl>

                </div>
            </fieldset>
        </div>
        
        <div id="formReservationBasicDatah1" class="fieldset formReservationBasicDatah1" style="display: none;">
            <fieldset>
                <legend style="background-color: #FFF;"><span>Pick up</span></legend>
                <div class="fieldset-box">

                    <dl class="formitem-fromBranch formitem">
                        <dt><label class="element" for="fromBranch">Pick up</label> </dt>
                        <dd>

                            <select name="pickup_loc_id" id="pickup_loc_id">
                                <optgroup label="Budva">
                                    <option value="1" selected="selected">Globtour Office</option>
                                    <option value="2">Hotel Avala</option>
                                    <option value="3">Hotel Slovenska Plaza</option>
                                    <option value="4">Hotel Mediteran</option>
                                    <option value="5">Hotel Iberostar</option>
                                </optgroup>
                                <optgroup label="Tivat">
                                    <option value="6">Airport +15&euro;</option>
                                    <option value="7">Hotel Palma +15&euro;</option>
                                </optgroup>
                                <optgroup label="Bar">
                                    <option value="8">Hotel Princess +15&euro;</option>
                                </optgroup>
                                <optgroup label="Ulcinj">
                                    <option value="9">Hotel Otrant +15&euro;</option>
                                    <option value="10">Hotel Ada Bojana +15&euro;</option>
                                </optgroup>
                                <optgroup label="Podgorica">
                                    <option value="11">Airport +15&euro;</option>
                                    <option value="12">Hotel Crna Gora +15&euro;</option>
                                    <option value="13">Hotel Podgorica +15&euro;</option>
                                </optgroup>
                            </select>


                        </dd>
                    </dl>
                    <dl class="formitem-fromDateGrp formitem">
                        <dt><label class="element">From</label> </dt>
                        <dd>
                            <input type="text" class="text" name="datefrom" id="datefrom" size="29" disabled="disabled"/>
                        </dd>
                    </dl>

                    <dl class="formitem-fromTimeGrp formitem">
                    <dt><label class="element">Time</label> </dt>
                    <dd>
                        <? echo makefull('fullfrom',15,'id="fullfrom" class="dd"'); ?>
                    </dd>

                </div>
            </fieldset>
        </div>

        <div id="formReservationBasicDatah2" class="fieldset formReservationBasicDatah2" style="display: none;">
            <fieldset>
                <legend><span>Return</span></legend>

                <div class="fieldset-box">

                    <dl class="formitem-destBranch formitem">
                        <dt><label class="element" for="destBranch">Return</label> </dt>

                        <dd>
                            <select name="return_loc_id" id="return_loc_id">
                                <optgroup label="Budva">
                                    <option value="1" selected="selected">Globtour Office</option>
                                    <option value="2">Hotel Avala</option>
                                    <option value="3">Hotel Slovenska Plaza</option>
                                    <option value="4">Hotel Mediteran</option>
                                    <option value="5">Hotel Iberostar</option>
                                </optgroup>
                                <optgroup label="Tivat">
                                    <option value="6">Airport +15&euro;</option>
                                    <option value="7">Hotel Palma +15&euro;</option>
                                </optgroup>
                                <optgroup label="Bar">
                                    <option value="8">Hotel Princess +15&euro;</option>
                                </optgroup>
                                <optgroup label="Ulcinj">
                                    <option value="9">Hotel Otrant +15&euro;</option>
                                    <option value="10">Hotel Ada Bojana +15&euro;</option>
                                </optgroup>
                                <optgroup label="Podgorica">
                                    <option value="11">Airport +15&euro;</option>
                                    <option value="12">Hotel Crna Gora +15&euro;</option>
                                    <option value="13">Hotel Podgorica +15&euro;</option>
                                </optgroup>
                            </select>

                        </dd>


                    </dl>

                    <dl class="formitem-fromDateGrp formitem">
                        <dt><label class="element">To</label> </dt>
                        <dd>
                            <input type="text" class="text" name="dateto" id="dateto" size="29" disabled="disabled"/>
                        </dd>
                    </dl>

                    <dl class="formitem-fromTimeGrp formitem">
                        <dt><label class="element">Time</label> </dt>
                        <dd>
                            <? echo makefull('fullto',15,'id="fullto" class="dd"'); ?>
                        </dd>

                    </dl>

                </div>
            </fieldset>
        </div>

        <div id="formReservationBasicDatah3" class="fieldset formReservationBasicDatah3" style="display: none;">
            <fieldset>
                <legend><span>Continue</span></legend>

                <input type="hidden" name="pickup_date" id="pickup_date">
                <input type="hidden" name="return_date" id="return_date">

                <div class="fieldset-box">
                    <dl class="formitem-formReservationBasicDataSubmit formitem">
                        <dt><label class="element" for="formReservationBasicDataSubmit">&nbsp;</label> </dt>

                        <dd><input type="submit" value="Change details" name="formReservationBasicDataSubmit" id="formReservationBasicDataSubmit" class="submit"></dd>
                    </dl>                            

                </div>
            </fieldset>
        </div>
        
    </div>
    
    <style>
        .dd {
            margin-bottom: 0;
        }
        .dd .ddTitle{
            width: 120px;
        }
        .dd .ddChild {
            width: 120px !important;
        }
    </style>

    <script type="text/javascript">
        $(function(){
            function init_app(){
                /***********************************************************
                * JQUERY UI Calendar with event
                ***********************************************************/

                var date = new Date();    

                //  limiter 1 WEBSITE PICUP DATE - today is not available
                //  limiter 0 SYSTEM PICUP DATE - today is available
                var limiter = 1;

                if(typeof(user_name) != "undefined"){
                    limiter = 0;   
                }

                var m = date.getMonth(),
                d = date.getDate() + limiter,
                y = date.getFullYear();

                img_url = base_url+'assets/img/backgnds/calendar.png';
                // Disable all dates till today
                $('#datefrom').datepicker({
                    minDate: new Date(y, m, d),
                    dateFormat: 'dd.mm.yy',
                    showOn: 'button',
                    buttonImage: img_url,
                    buttonImageOnly: true,
                    onSelect: function(dateStr) {

                        var depart = $.datepicker.parseDate('dd.mm.yy', dateStr);
                        depart.setDate(depart.getDate() + limiter);
                        $('#dateto').datepicker("setDate", depart);
                        $('#dateto').datepicker("option", "minDate", depart);

                        $('#pickup_date').val($.datepicker.formatDate('dd.mm.yy', $('#datefrom').datepicker('getDate')));
                        $('#return_date').val($.datepicker.formatDate('dd.mm.yy', $('#dateto').datepicker('getDate')));

                    }
                });

                $('#dateto').datepicker({
                    minDate: new Date(y, m, d),
                    dateFormat: 'dd.mm.yy',
                    showOn: 'button',
                    buttonImage: img_url,
                    buttonImageOnly: true,
                    onSelect: function(dateStr) {
                        $('#return_date').val($.datepicker.formatDate('dd.mm.yy', $('#dateto').datepicker('getDate')));
                    }
                })

                // SET TIME & DATE
                $('#fullfrom').val('08:00');
                $('#fullto').val('08:00');

                $('#datefrom').datepicker('setDate', new Date(y, m, d));
                $('#dateto').datepicker('setDate', new Date(y, m, d+1));

                $('#pickup_date').val($.datepicker.formatDate('dd.mm.yy', $('#datefrom').datepicker('getDate')));
                $('#return_date').val($.datepicker.formatDate('dd.mm.yy', $('#dateto').datepicker('getDate')));


            }
            init_app();    
        })
    </script>

    <script language="javascript">
        $(document).ready(function(e) {
            try {
                $("body select.dd").msDropDown();
            } catch(e) {
                alert(e.message);
            }

            $('#pickup_loc_id').live('change', function(){

                var sID = $('#pickup_loc_id option:selected').val(); 
                var $dd = $('#return_loc_id');
                if ($dd.length > 0) { // make sure we found the select we were looking for

                    // save the selected value
                    var selectedVal = $dd.val();

                    // get the options and loop through them
                    var $options = $('option', $dd);
                    var arrVals = [];
                    $options.each(function(){

                        if($(this).val()==sID||$(this).val()==1||$(this).val()==6||$(this).val()==11){

                            $(this).removeAttr('disabled');

                        }else{
                            $(this).attr('disabled','disabled');
                            //console.log($(this).text())
                            //console.log($(this).val())
                        }
                    });
                }
                $('#return_loc_id').val(sID).trigger('change');


            })

            $('#pickup_loc_id').val(1).trigger('change');

        });
    </script>

    <?}?>